﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >
    <Style TargetType="{x:Type Control}">
        <Setter Property="Focusable" Value="False" />
    </Style>
    <Storyboard x:Key="FlashElementStoryboard">
        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" 
                                           Storyboard.TargetProperty="(UIElement.Visibility)">
            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
            <DiscreteObjectKeyFrame KeyTime="00:00:00.2000000" Value="{x:Static Visibility.Visible}"/>
            <DiscreteObjectKeyFrame KeyTime="00:00:00.4000000" Value="{x:Static Visibility.Hidden}"/>
            <DiscreteObjectKeyFrame KeyTime="00:00:00.6000000" Value="{x:Static Visibility.Visible}"/>
            <DiscreteObjectKeyFrame KeyTime="00:00:00.8000000" Value="{x:Static Visibility.Hidden}"/>
            <DiscreteObjectKeyFrame KeyTime="00:00:01" Value="{x:Static Visibility.Visible}"/>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    <ControlTemplate x:Key="ErrorTemplate">
        <DockPanel LastChildFill="True"
            ToolTip="{Binding ElementName=myControl, 
                        Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
            <Grid DockPanel.Dock="Right" Margin="-18,-3,0,0">
                <Ellipse Width="15" Height="15" HorizontalAlignment="Center"
                     StrokeThickness="1" Fill="Red" VerticalAlignment="Center"
                     >
                    <Ellipse.Stroke>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#FFFA0404" Offset="0"/>
                            <GradientStop Color="#FFC9C7C7" Offset="1"/>
                        </LinearGradientBrush>
                    </Ellipse.Stroke>
                </Ellipse>
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"
                           Foreground="White"
                            FontSize="9pt" 
                            FontWeight="Bold">!
                </TextBlock>
                <Grid.Triggers>
                    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                        <BeginStoryboard Storyboard="{StaticResource FlashElementStoryboard}"/>
                    </EventTrigger>
                </Grid.Triggers>
            </Grid>
            <AdornedElementPlaceholder Name="myControl" 
                                       />
        </DockPanel>
    </ControlTemplate>
    <ControlTemplate x:Key="ErrorTemplateExtraOffset">
        <DockPanel LastChildFill="True"
            ToolTip="{Binding ElementName=myControl, 
                        Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
            <Grid DockPanel.Dock="Right" Margin="-38,-3,0,0">
                <Ellipse Width="15" Height="15" HorizontalAlignment="Center"
                     StrokeThickness="1" Fill="Red" VerticalAlignment="Center"
                     >
                    <Ellipse.Stroke>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#FFFA0404" Offset="0"/>
                            <GradientStop Color="#FFC9C7C7" Offset="1"/>
                        </LinearGradientBrush>
                    </Ellipse.Stroke>
                </Ellipse>
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"
                           Foreground="White"
                            FontSize="9pt" 
                            FontWeight="Bold">!
                </TextBlock>
                <Grid.Triggers>
                    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                        <BeginStoryboard Storyboard="{StaticResource FlashElementStoryboard}"/>
                    </EventTrigger>
                </Grid.Triggers>
            </Grid>
            <AdornedElementPlaceholder Name="myControl" 
                                       />
        </DockPanel>
    </ControlTemplate>
</ResourceDictionary>

